package service

import (
	"cgs-server/server/cgs/app/store"
)

type Service interface {
	WorksheetGroup() WorksheetGroupSrv
	WorksheetShortCut() WorksheetShortCutSrv
	WorksheetView() WorksheetViewSrv
	WorksheetInfo() WorksheetInfoSrv
	WorksheetRows() WorksheetRowsSrv
	WorksheetPrint() WorksheetPrintSrv
	App() AppSrv
	Market() MarketSrv
	PublicWorksheet() PublicWorksheetSrv
}

type service struct {
	store store.Factory
}

func (s *service) PublicWorksheet() PublicWorksheetSrv {
	return newPublicWorksheetSrv(s)
}

func (s *service) WorksheetShortCut() WorksheetShortCutSrv {
	return newWorksheetShortCutSrv(s)
}

func (s *service) Market() MarketSrv {
	return newMarketSrv(s)
}

func (s *service) WorksheetPrint() WorksheetPrintSrv {
	return newWorksheetPrintSrv(s)
}

func (s *service) App() AppSrv {
	return newAppSrv(s)
}

func (s *service) WorksheetRows() WorksheetRowsSrv {
	return newWorksheetRowsSrv(s)
}

func (s *service) WorksheetInfo() WorksheetInfoSrv {
	return newWorksheetInfoSrv(s)
}

func (s *service) WorksheetView() WorksheetViewSrv {
	return newWorksheetViewSrv(s)
}

func (s *service) WorksheetGroup() WorksheetGroupSrv {
	return newWorksheetGroupSrv(s)
}

func NewService(store store.Factory) Service {
	return &service{store: store}
}

var serviceImpl Service

func Client() Service {
	return serviceImpl
}

func SetClient(store store.Factory) {
	serviceImpl = NewService(store)
}
